#ifndef _GAME_SCENE_2_H_
#define _GAME_SCENE_2_H_

#include "scene.h"
#include "scene_manager.h"
#include "platform.h"
#include "wall.h"
#include "collision_box_manager.h"
#include "collision_box.h"
#include "player.h"
#include "item.h"

#include<iostream>

extern IMAGE img_MAIN_MENU;
extern IMAGE img_ground_soil;

extern Camera main_camera;
extern std::vector<Platform> platform_list;
extern std::vector<Wall> wall_list;
extern std::vector<Collision_box> collision_box_list_02;
extern std::vector<Item*> apples_02;

extern Atlas atlas_apple;
extern Atlas atlas_apple_eaten;


Collision_box collision_box_02_03 = Collision_box({ 63,622 }, { 150,700 });
Collision_box collision_box_02_04 = Collision_box({ 140,563 }, { 217,622 });
Collision_box collision_box_02_05 = Collision_box({ 186,486 }, { 553,563 });
Collision_box collision_box_02_06 = Collision_box({ 523,563 }, { 689,660 });
Collision_box collision_box_02_07 = Collision_box({ 682,660 }, { 915,750 });
Collision_box collision_box_02_08 = Collision_box({ 866,579 }, { 1231,700 });
Collision_box collision_box_02_test = Collision_box({ 100,200 }, { 300,300 });

Item* apple_01_2 = new Item(100, 300);
Item* apple_02_2 = new Item(150, 300);

extern SceneManager scene_manager;
extern Collision_box_manager collision_box_manager;
extern Player* player;

extern Vector2 pre_pos_game_scene;
extern Vector2 pre_spd_game_scene;


extern bool is_debug;
class GameScene2 :public Scene
{

public:
	GameScene2()
	{

	}

	~GameScene2()
	{

	}

	void on_enter()
	{
		player->set_pos(pre_pos_game_scene.x-1280, pre_pos_game_scene.y);
		player->set_spd(pre_spd_game_scene.x, pre_spd_game_scene.y);
		collision_box_list_02.push_back(collision_box_02_03);
		collision_box_list_02.push_back(collision_box_02_04);
		collision_box_list_02.push_back(collision_box_02_05);
		collision_box_list_02.push_back(collision_box_02_06);
		collision_box_list_02.push_back(collision_box_02_07);
		collision_box_list_02.push_back(collision_box_02_08);
		collision_box_list_02.push_back(collision_box_02_test);
		apples_02.push_back(apple_01_2);
		apples_02.push_back(apple_02_2);


	}
	void on_update(int delta)
	{
		menu_ground_scorll_offset_y += 3;
		if (menu_ground_scorll_offset_y >= img_MAIN_MENU.getheight())
			menu_ground_scorll_offset_y = 0;
		player->on_update(delta);
		for (Item* apple : apples_01)
		{
			apple->on_update(delta);
		}
	}
	void on_draw(const Camera& camera)
	{
		putimage_alpha(-100, menu_ground_scorll_offset_y, 0, img_MAIN_MENU.getheight() - menu_ground_scorll_offset_y, &img_MAIN_MENU, 0, 0);
		putimage_alpha(-100, -img_MAIN_MENU.getheight() + 1 + menu_ground_scorll_offset_y, 0, 0, &img_MAIN_MENU, 0, 0);
		putimage_alpha(camera, 50, 485, &img_ground_soil);
		player->on_draw(camera);

		collision_box_manager.on_draw(camera);
		if (is_debug)
		{
			settextcolor(RGB(255, 0, 0));
			outtextxy(15, 15, _T("debug mode on_2"));
			outtextxy(15, 40, is_collide_b ? _T("B:TRUE") : _T("B:FALSE"));
			outtextxy(15, 80, is_collide_t ? _T("T:TRUE") : _T("T:FALSE"));
			outtextxy(15, 120, is_collide_l ? _T("L:TRUE") : _T("L:FALSE"));
			outtextxy(15, 160, is_collide_r ? _T("R:TRUE") : _T("R:FALSE"));
		}
		for (Item* apple : apples_01)
		{
			apple->on_draw(camera);
		}
	}
	void on_input(const ExMessage& msg)
	{
		
		switch (msg.message)
		{
		case WM_KEYDOWN:
			if (msg.vkcode == 0x51)
				is_debug = !is_debug;
			break;
		default:
			break;
		}
		player->on_input(msg);
	}
	void on_exit()
	{

	}

private:

	int menu_ground_scorll_offset_y = 0;
};



#endif


